use std::borrow::Cow;

use super::Cmd;


pub struct MoveJ {
    jt_cur_pos: [f64; 6],
    tl_cur_pos: [f64; 6],
    speed: f32,
    acc: f32,
    bland_t: f32,
}

impl Cmd for MoveJ {

    fn cmd_id(&self) -> u32 {
        MoveJ::CMD_ID
    }

    fn to_string(&self) -> Cow<'static, str> {
        let data = format!("MoveJ({:.3},{:.3},{:.3},{:.3},{:.3},{:.3},{:.3},{:.3},{:.3},{:.3},{:.3},{:.3},0,0,{},{},100,0.000,0.000.0.000.0.000,{:.3},0,0.000,0.000,0.000,0.000,0.000,0.000)",
            self.jt_cur_pos[0],
            self.jt_cur_pos[1],
            self.jt_cur_pos[2],
            self.jt_cur_pos[3],
            self.jt_cur_pos[4],
            self.jt_cur_pos[5],
            self.tl_cur_pos[0],
            self.tl_cur_pos[1],
            self.tl_cur_pos[2],
            self.tl_cur_pos[3],
            self.tl_cur_pos[4],
            self.tl_cur_pos[5],
            self.speed,
            self.acc,
            self.bland_t
        );
        Cow::Owned(data)
    }
}

impl MoveJ {
    const CMD_ID: u32 = 201;

    pub fn new(
        jt_cur_pos: [f64; 6],
        tl_cur_pos: [f64; 6],
        speed: f32,
        acc: f32,
        bland_t: f32,
    ) -> Self {
        Self {
            jt_cur_pos,
            tl_cur_pos,
            speed,
            acc,
            bland_t,
        }
    }
}
